package Day;

public class Date {
    private int  year;//年
    private int  month;//月
    private int day;//日
    public Date(){

    }
    public Date(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public Date(Date copyDate){
        this.day = copyDate.day;
        this.month = copyDate.month;
        this.year = copyDate.year;
    }
    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public void tomorrow(){
        int tYear=0;//初始化都为0
        int tMonth=0;
        int tDay=0;
       switch (month){
           case 1:
           case 3:
           case 5:
           case 7:
           case 8:
           case 10:
           case 12:
               if(day==31&&month!=12){
                   tDay = 1;
                   tMonth = month +1;
                   tYear = year;
               }else if(month==12&&day==31){
                   tDay = 1;
                   tMonth = 1;
                   tYear = year+1;
               }else {
                   tDay = day+1;
                   tMonth = month;
                   tYear = year;
               }
               break;
           case 4:
           case 6:
           case 9:
           case 11:
               if(day==30){
                   tDay = 1;
                   tMonth = month +1;
               }else {
                   tDay = day+1;
                   tMonth = month;
               }
               tYear = year;
           case 2:
               //判断是否为闰年的二月
               if(year%4==0&&year%100!=0){
                   if(day==29){
                       tDay = 1;
                       tMonth = month +1;
                   }else {
                       tDay = day+1;
                       tMonth = month;
                   }
               }else{
                   if(day==28){
                       tDay = 1;
                       tMonth = month +1;
                   }
                   else {
                       tDay = day + 1;
                       tMonth = month;
                   }
               }
               tYear = year;
               break;
           default:
               break;
       }
        System.out.println("tomorrow:"+tYear+"年"+tMonth+"月"+tDay+"日");
    }
    public void yesterday(){
        int yYear=0;//初始化都为0
        int yMonth=0;
        int yDay=0;
        switch (month){
            case 1:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                if(day==1&&month!=1){
                    yDay = 31;
                    yMonth = month-1;
                    yYear = year;
                }else if(month==1&&day==1){
                    yDay = 31;
                    yMonth =12;
                    yYear = year-1;
                }else {
                    yDay = day-1;
                    yMonth = month;
                    yYear = year;
                }
                break;
            case 4:
            case 2:
            case 6:
            case 9:
            case 11:
                if(day==1){
                    yDay = 30;
                    yMonth = month - 1;
                }else {
                    yDay = day-1;
                    yMonth = month;
                }
                yYear = year;
            case 3:
                //判断是否为闰年的3月
                if(year%4==0&&year%100!=0){
                    if(day==1){
                        yDay = 29;
                        yMonth = month -1;
                    }else {
                        yDay = day-1;
                        yMonth = month;
                    }
                }else{
                    if(day==1){
                        yDay = 28;
                        yMonth = month -1;
                    }
                    else {
                        yDay = day -1;
                        yMonth = month;
                    }
                }
                yYear = year;
                break;
            default:
                break;
        }
        System.out.println("yesterday:"+yYear+"年"+yMonth+"月"+yDay+"日");
    }
    //判断今天是今年的第几天
    public void daysInYear(){
        int days=0;
        int sumDays = 0;//总的天数
        switch (month){
            //将天数从1月到month累加起来
            case 12:sumDays+=30;//11月的总天数
            case 11:sumDays+=31;//10月的总天数
            case 10:sumDays+=30;
            case 9:sumDays+=31;
            case 8:sumDays+=31;
            case 7:sumDays+=30;
            case 6:sumDays+=31;
            case 5:sumDays+=30;
            case 4:sumDays+=31;
            case 3:
                //判断是否为闰年的3月
                if(year%4==0&&year%100!=0){
                    sumDays+=29;
                }else{
                    sumDays+=28;
                }
            case 2:sumDays+=31;
            case 1:sumDays+= day;
            default:
                break;
        }
        System.out.println("days in the year:"+sumDays);
    }
}
